package com.example.controller;

import com.example.common.Result;
import com.example.entity.Business;
import com.example.entity.User;
import com.example.service.BusinessService;
import com.example.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WebController {

    @Resource
    private UserService userService;

    @Resource
    private BusinessService businessService;

    @PostMapping("/login/business")
    public Result login(@RequestBody Business business) {
        Business loginBusiness = businessService.login(business);
        return Result.success(loginBusiness);
    }
    @PostMapping("/login/user")
    public Result login(@RequestBody User user) {
        User loginUser = userService.login(user);
        return Result.success(loginUser);
    }

    @PostMapping("/register/business")
    public Result register(@RequestBody Business business) {
        businessService.register(business);
        return Result.success();
    }

    @PostMapping("/register/user")
    public Result register(@RequestBody User user) {
        userService.register(user);
        return Result.success();
    }



}
